/*   1:    */ package com.rinsi.app.azsb;
/*   2:    */ 
/*   3:    */ import com.rinsi.core.CoreCache;
/*   4:    */ import com.rinsi.core.service.CoreSimpleService;
/*   5:    */ import com.rinsi.util.AssertUtil;
/*   6:    */ import com.rinsi.util.FileUtil;
/*   7:    */ import com.rinsi.util.MapUtil;
/*   8:    */ import com.rinsi.util.SpringContextUtil;
/*   9:    */ import java.io.PrintStream;
/*  10:    */ import java.util.List;
/*  11:    */ import java.util.Map;
/*  12:    */ import org.mybatis.spring.SqlSessionTemplate;
/*  13:    */ import org.springframework.stereotype.Service;
/*  14:    */ 
/*  15:    */ @Service
/*  16:    */ public class AzsbService
/*  17:    */   extends CoreSimpleService
/*  18:    */ {
/*  19:    */   public void afterIndex(Map<String, Object> model, Map<String, Object> rMap)
/*  20:    */   {
/*  21: 21 */     Map<String, Object> config = getConfig(model);
/*  22:    */     
/*  23: 23 */     Map<String, Object> params = getParams(model);
/*  24:    */     
/*  25: 25 */     params.put("CODE_NO", Integer.valueOf(500005));
/*  26:    */     
/*  27: 27 */     Map<String, Object> organ = CoreCache.getCacheMap(MapUtil.getString(params, "UID"), "organ");
/*  28:    */     
/*  29: 29 */     params.put("ORGAN_TYPE", MapUtil.getString(organ, "ORGAN_TYPE"));
/*  30:    */     
/*  31: 31 */     rMap.put("sblxs", getSqlSessionTemplate().selectList(namespace(config) + ".sblxs", params));
/*  32:    */   }
/*  33:    */   
/*  34:    */   public Map<String, Object> save(Map<String, Object> model)
/*  35:    */   {
/*  36: 39 */     Map<String, Object> params = getParams(model);
/*  37:    */     
/*  38: 41 */     Map<String, Object> config = getConfig(model);
/*  39:    */     
/*  40: 43 */     Map<String, Object> rMap = getRMap();
/*  41:    */     try
/*  42:    */     {
/*  43: 47 */       if (!AssertUtil.isStringNotEmpty(params.get(config.get("module.idCol"))))
/*  44:    */       {
/*  45: 49 */         int goQyzl = ((Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".goQyzl", params)).intValue();
/*  46:    */         
/*  47: 51 */         int goMkzl = ((Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".goMkzl", params)).intValue();
/*  48:    */         
/*  49: 53 */         int i = 0;
/*  50:    */         
/*  51: 55 */         int temp = 0;
/*  52: 57 */         if ((goQyzl == 1) && (goMkzl == 1))
/*  53:    */         {
/*  54: 59 */           temp = ((Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkedAll", params)).intValue();
/*  55: 61 */           if (temp == 0) {
/*  56: 63 */             i = 0;
/*  57:    */           } else {
/*  58: 67 */             i = 3;
/*  59:    */           }
/*  60:    */         }
/*  61: 71 */         else if ((goQyzl == 1) && (goMkzl == 0))
/*  62:    */         {
/*  63: 73 */           temp = ((Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkedQyzl", params)).intValue();
/*  64: 75 */           if (temp == 0) {
/*  65: 77 */             i = 1;
/*  66:    */           } else {
/*  67: 81 */             i = 3;
/*  68:    */           }
/*  69:    */         }
/*  70: 85 */         else if ((goQyzl == 0) && (goMkzl == 1))
/*  71:    */         {
/*  72: 87 */           temp = ((Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkedMkzl", params)).intValue();
/*  73: 89 */           if (temp == 0) {
/*  74: 91 */             i = 2;
/*  75:    */           } else {
/*  76: 95 */             i = 3;
/*  77:    */           }
/*  78:    */         }
/*  79:    */         else
/*  80:    */         {
/*  81:101 */           i = 3;
/*  82:    */         }
/*  83:106 */         String key = getKey(config);
/*  84:    */         
/*  85:108 */         params.put(MapUtil.getString(config, "module.idCol"), key);
/*  86:110 */         if (!params.get("AZSB_LX").equals("5"))
/*  87:    */         {
/*  88:112 */           if (i == 0)
/*  89:    */           {
/*  90:114 */             rMap.put("shoeExMessage", Boolean.valueOf(true));
/*  91:    */             
/*  92:116 */             throw new Exception("企业信息或煤矿信息未归档，请检查后重新申报！");
/*  93:    */           }
/*  94:118 */           if (i == 1)
/*  95:    */           {
/*  96:120 */             rMap.put("shoeExMessage", Boolean.valueOf(true));
/*  97:    */             
/*  98:122 */             throw new Exception("企业信息未归档，请检查后重新申报！");
/*  99:    */           }
/* 100:124 */           if (i == 2)
/* 101:    */           {
/* 102:126 */             rMap.put("shoeExMessage", Boolean.valueOf(true));
/* 103:    */             
/* 104:128 */             throw new Exception("煤矿信息未归档，请检查后重新申报！");
/* 105:    */           }
/* 106:132 */           Map<String, Object> jbxx = (Map)getSqlSessionTemplate().selectOne(namespace(config) + ".getJbxx", params);
/* 107:    */           
/* 108:134 */           params.putAll(jbxx);
/* 109:    */         }
/* 110:    */         else
/* 111:    */         {
/* 112:138 */           String Qyxx = getSqlSessionTemplate().selectOne(namespace(config) + ".getQyxx", params).toString();
/* 113:    */           
/* 114:140 */           params.put("KJJBXX_SSQYMC", Qyxx);
/* 115:    */         }
/* 116:143 */         String ORGAN_CODE = getSqlSessionTemplate().selectOne(namespace(config) + ".selectOrganCode", params).toString();
/* 117:    */         
/* 118:145 */         String sqcs = String.valueOf(((Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".selectSqcs", params)).intValue() + 1);
/* 119:147 */         if (params.get("AZSB_LX").equals("5")) {
/* 120:149 */           params.put("AZSB_SQBH", "Q" + ORGAN_CODE + sqcs);
/* 121:    */         }
/* 122:153 */         if (params.get("AZSB_LX").equals("1")) {
/* 123:155 */           params.put("AZSB_SQBH", "S" + ORGAN_CODE + sqcs);
/* 124:    */         }
/* 125:159 */         if (params.get("AZSB_LX").equals("6")) {
/* 126:161 */           params.put("AZSB_SQBH", "G" + ORGAN_CODE + sqcs);
/* 127:    */         }
/* 128:165 */         if (params.get("AZSB_LX").equals("2")) {
/* 129:167 */           params.put("AZSB_SQBH", "Y" + ORGAN_CODE + sqcs);
/* 130:    */         }
/* 131:171 */         if (params.get("AZSB_LX").equals("3")) {
/* 132:173 */           params.put("AZSB_SQBH", "Z" + ORGAN_CODE + sqcs);
/* 133:    */         }
/* 134:177 */         if (params.get("AZSB_LX").equals("4")) {
/* 135:179 */           params.put("AZSB_SQBH", "B" + ORGAN_CODE + sqcs);
/* 136:    */         }
/* 137:183 */         params.put("AZSB_KCLX", Integer.valueOf(1));
/* 138:    */         
/* 139:185 */         getSqlSessionTemplate().insert(namespace(config) + ".insert", params);
/* 140:    */         
/* 141:187 */         getSqlSessionTemplate().insert(namespace(config) + ".init", params);
/* 142:    */         
/* 143:189 */         getSqlSessionTemplate().insert(namespace(config) + ".createFlow", params);
/* 144:    */       }
/* 145:    */       else
/* 146:    */       {
/* 147:193 */         beforeUpdate(model);
/* 148:    */         
/* 149:195 */         getSqlSessionTemplate().update(namespace(config) + ".update", params);
/* 150:    */       }
/* 151:198 */       rMap.put("data", getSqlSessionTemplate().selectOne(namespace(config) + ".get", params));
/* 152:    */     }
/* 153:    */     catch (Exception ex)
/* 154:    */     {
/* 155:202 */       ex.printStackTrace();
/* 156:    */       
/* 157:204 */       rMap.put("success", Boolean.valueOf(false));
/* 158:206 */       if (MapUtil.getBoolean(rMap, "shoeExMessage").booleanValue()) {
/* 159:208 */         rMap.put("message", ex.getMessage());
/* 160:    */       } else {
/* 161:212 */         rMap.put("message", "保存数据出错！请稍后重试，或联系系统管理员！");
/* 162:    */       }
/* 163:    */     }
/* 164:216 */     return rMap;
/* 165:    */   }
/* 166:    */   
/* 167:    */   public void beforeList(Map<String, Object> model)
/* 168:    */   {
/* 169:222 */     Map<String, Object> params = getParams(model);
/* 170:    */     
/* 171:224 */     params.put("ORGAN_ID", CoreCache.getCacheMap(MapUtil.getString(params, "UID"), "organ").get("ORGAN_ID"));
/* 172:    */   }
/* 173:    */   
/* 174:    */   public Map<String, Object> azsb(Map<String, Object> model)
/* 175:    */   {
/* 176:231 */     Map<String, Object> params = getParams(model);
/* 177:    */     
/* 178:233 */     Map<String, Object> config = getConfig(model);
/* 179:    */     
/* 180:235 */     Map<String, Object> rMap = getRMap();
/* 181:    */     
/* 182:237 */     Map<String, Object> organ = CoreCache.getCacheMap(MapUtil.getString(params, "UID"), "organ");
/* 183:    */     try
/* 184:    */     {
/* 185:240 */       String[] IDs = MapUtil.getString(params, "IDs").split(",");
/* 186:242 */       for (int i = 0; i < IDs.length; i++)
/* 187:    */       {
/* 188:244 */         params.put(MapUtil.getString(config, "module.idCol"), IDs[i].trim());
/* 189:    */         
/* 190:246 */         params.putAll((Map)getSqlSessionTemplate().selectOne(namespace(config) + ".get", params));
/* 191:    */         
/* 192:248 */         params.put("ORGAN_TYPE", MapUtil.getInteger(organ, "ORGAN_TYPE"));
/* 193:    */         
/* 194:    */ 
/* 195:251 */         Integer contSqsqz = (Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkSqsSQ", params);
/* 196:253 */         if (contSqsqz.intValue() == 0)
/* 197:    */         {
/* 198:255 */           rMap.put("shoeExMessage", Boolean.valueOf(true));
/* 199:    */           
/* 200:257 */           throw new Exception("申请书尚未签章！不能上报！");
/* 201:    */         }
/* 202:261 */         Integer contScsSc = (Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkScsSc", params);
/* 203:263 */         if (contScsSc.intValue() > 0)
/* 204:    */         {
/* 205:265 */           rMap.put("shoeExMessage", Boolean.valueOf(true));
/* 206:    */           
/* 207:267 */           throw new Exception("审查书尚未上传完附件！不能上报！");
/* 208:    */         }
/* 209:282 */         String mod = MapUtil.getString((Map)model.get("module"), "MODULE_NO");
/* 210:    */         
/* 211:284 */         String filepath = (String)((Map)SpringContextUtil.getBean("config")).get("filepath") + mod + "/";
/* 212:    */         
/* 213:286 */         filepath = filepath + params.get("AZSB_ID");
/* 214:288 */         if (2 == MapUtil.getInteger(organ, "ORGAN_TYPE").intValue())
/* 215:    */         {
/* 216:290 */           List<Map<String, Object>> files = FileUtil.getFileList(filepath);
/* 217:292 */           if (files.size() == 0)
/* 218:    */           {
/* 219:294 */             rMap.put("shoeExMessage", Boolean.valueOf(true));
/* 220:    */             
/* 221:296 */             throw new Exception("征求意见书尚未上传！不能上报！");
/* 222:    */           }
/* 223:301 */           Integer contXcjc = (Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkXcjc", params);
/* 224:303 */           if (contXcjc.intValue() == 0)
/* 225:    */           {
/* 226:305 */             rMap.put("shoeExMessage", Boolean.valueOf(true));
/* 227:    */             
/* 228:307 */             throw new Exception("现场监察情况尚未签章！不能上报！");
/* 229:    */           }
/* 230:    */         }
/* 231:312 */         getSqlSessionTemplate().update(namespace(config) + ".azsb", params);
/* 232:    */       }
/* 233:315 */       rMap.put("data", getSqlSessionTemplate().selectOne(namespace(config) + ".get", params));
/* 234:    */     }
/* 235:    */     catch (Exception ex)
/* 236:    */     {
/* 237:319 */       rMap.put("success", Boolean.valueOf(false));
/* 238:321 */       if (MapUtil.getBoolean(rMap, "shoeExMessage").booleanValue()) {
/* 239:323 */         rMap.put("message", ex.getMessage());
/* 240:    */       } else {
/* 241:327 */         rMap.put("message", "数据上报出错！请稍后重试，或联系系统管理员！");
/* 242:    */       }
/* 243:330 */       rMap.put("ex", ex.getMessage());
/* 244:    */       
/* 245:332 */       ex.printStackTrace();
/* 246:    */     }
/* 247:335 */     afterLock(model, rMap);
/* 248:    */     
/* 249:337 */     return rMap;
/* 250:    */   }
/* 251:    */   
/* 252:    */   public Map<String, Object> checkMsg(Map<String, Object> model)
/* 253:    */   {
/* 254:342 */     Map<String, Object> params = getParams(model);
/* 255:    */     
/* 256:344 */     Map<String, Object> config = getConfig(model);
/* 257:    */     
/* 258:346 */     Map<String, Object> rMap = getRMap();
/* 259:    */     try
/* 260:    */     {
/* 261:350 */       Integer count = (Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkUnlock", params);
/* 262:352 */       if (count.intValue() == 0)
/* 263:    */       {
/* 264:354 */         rMap.put("success", Boolean.valueOf(true));
/* 265:    */       }
/* 266:    */       else
/* 267:    */       {
/* 268:358 */         rMap.put("success", Boolean.valueOf(false));
/* 269:    */         
/* 270:360 */         rMap.put("message", "您还有未完成的安证申报,不能再次申请！");
/* 271:    */       }
/* 272:    */     }
/* 273:    */     catch (Exception ex)
/* 274:    */     {
/* 275:366 */       rMap.put("success", Boolean.valueOf(false));
/* 276:368 */       if (MapUtil.getBoolean(rMap, "shoeExMessage").booleanValue()) {
/* 277:370 */         rMap.put("message", ex.getMessage());
/* 278:    */       } else {
/* 279:374 */         rMap.put("message", "数据加锁出错！请稍后重试，或联系系统管理员！");
/* 280:    */       }
/* 281:377 */       rMap.put("ex", ex.getMessage());
/* 282:    */       
/* 283:379 */       ex.printStackTrace();
/* 284:    */     }
/* 285:383 */     return rMap;
/* 286:    */   }
/* 287:    */   
/* 288:    */   public Map<String, Object> checkScxx(Map<String, Object> model)
/* 289:    */   {
/* 290:388 */     Map<String, Object> params = getParams(model);
/* 291:    */     
/* 292:390 */     Map<String, Object> config = getConfig(model);
/* 293:    */     
/* 294:392 */     Map<String, Object> rMap = getRMap();
/* 295:    */     
/* 296:394 */     params.put("AQSCXKZSCS_SCYJ", "不符合规定");
/* 297:    */     try
/* 298:    */     {
/* 299:398 */       Integer organType = (Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".getOrganType", params);
/* 300:    */       
/* 301:400 */       params.put("ORGAN_TYPE", organType);
/* 302:    */       
/* 303:402 */       Integer count = Integer.valueOf(0);
/* 304:404 */       if ((organType.intValue() == 1) || (organType.intValue() == 2)) {
/* 305:406 */         count = (Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".checkScxx", params);
/* 306:    */       }
/* 307:410 */       if (count.intValue() == 0)
/* 308:    */       {
/* 309:412 */         rMap.put("success", Boolean.valueOf(true));
/* 310:    */       }
/* 311:    */       else
/* 312:    */       {
/* 313:416 */         rMap.put("success", Boolean.valueOf(false));
/* 314:418 */         if (organType.intValue() == 1) {
/* 315:420 */           rMap.put("message", "审查书有" + count + "条数据不合格，是否进行编辑？");
/* 316:422 */         } else if (organType.intValue() == 2) {
/* 317:424 */           rMap.put("message", "监察审核有" + count + "条数据不合格，是否进行编辑？");
/* 318:    */         }
/* 319:    */       }
/* 320:    */     }
/* 321:    */     catch (Exception ex)
/* 322:    */     {
/* 323:432 */       rMap.put("success", Boolean.valueOf(false));
/* 324:434 */       if (MapUtil.getBoolean(rMap, "shoeExMessage").booleanValue()) {
/* 325:436 */         rMap.put("message", ex.getMessage());
/* 326:    */       } else {
/* 327:440 */         rMap.put("message", "数据加锁出错！请稍后重试，或联系系统管理员！");
/* 328:    */       }
/* 329:443 */       rMap.put("ex", ex.getMessage());
/* 330:    */       
/* 331:445 */       ex.printStackTrace();
/* 332:    */     }
/* 333:449 */     return rMap;
/* 334:    */   }
/* 335:    */   
/* 336:    */   public Map<String, Object> changeShzt(Map<String, Object> model)
/* 337:    */   {
/* 338:454 */     Map<String, Object> params = getParams(model);
/* 339:    */     
/* 340:456 */     Map<String, Object> config = getConfig(model);
/* 341:    */     
/* 342:458 */     Map<String, Object> rMap = getRMap();
/* 343:    */     try
/* 344:    */     {
/* 345:462 */       getSqlSessionTemplate().update(namespace(config) + ".changeShzt", params);
/* 346:    */       
/* 347:464 */       rMap.put("success", Boolean.valueOf(true));
/* 348:    */     }
/* 349:    */     catch (Exception ex)
/* 350:    */     {
/* 351:468 */       rMap.put("success", Boolean.valueOf(false));
/* 352:    */       
/* 353:470 */       rMap.put("ex", ex.getMessage());
/* 354:    */       
/* 355:472 */       ex.printStackTrace();
/* 356:    */     }
/* 357:476 */     return rMap;
/* 358:    */   }
/* 359:    */   
/* 360:    */   public Map<String, Object> ISCK(Map<String, Object> model)
/* 361:    */   {
/* 362:481 */     Map<String, Object> params = getParams(model);
/* 363:    */     
/* 364:483 */     Map<String, Object> config = getConfig(model);
/* 365:    */     
/* 366:485 */     Map<String, Object> rMap = getRMap();
/* 367:    */     try
/* 368:    */     {
/* 369:489 */       Integer ORGAN_TYPE = (Integer)getSqlSessionTemplate().selectOne(namespace(config) + ".ISCK", params);
/* 370:    */       
/* 371:491 */       System.out.println(ORGAN_TYPE);
/* 372:493 */       if (ORGAN_TYPE.intValue() == 9) {
/* 373:495 */         rMap.put("success", Boolean.valueOf(true));
/* 374:    */       } else {
/* 375:499 */         rMap.put("success", Boolean.valueOf(false));
/* 376:    */       }
/* 377:    */     }
/* 378:    */     catch (Exception ex)
/* 379:    */     {
/* 380:505 */       rMap.put("success", Boolean.valueOf(false));
/* 381:    */     }
/* 382:509 */     return rMap;
/* 383:    */   }
/* 384:    */   
/* 385:    */   public Map<String, Object> showTzs(Map<String, Object> model)
/* 386:    */   {
/* 387:514 */     Map<String, Object> params = getParams(model);
/* 388:    */     
/* 389:516 */     Map<String, Object> config = getConfig(model);
/* 390:    */     
/* 391:518 */     Map<String, Object> rMap = getRMap();
/* 392:    */     try
/* 393:    */     {
/* 394:522 */       Map<String, Object> tzsMsg = (Map)getSqlSessionTemplate().selectOne(namespace(config) + ".showTzs", params);
/* 395:    */       
/* 396:524 */       rMap.put("tzsMsg", tzsMsg);
/* 397:    */       
/* 398:526 */       rMap.put("success", Boolean.valueOf(true));
/* 399:    */     }
/* 400:    */     catch (Exception ex)
/* 401:    */     {
/* 402:530 */       rMap.put("success", Boolean.valueOf(false));
/* 403:    */       
/* 404:532 */       rMap.put("ex", ex.getMessage());
/* 405:    */     }
/* 406:536 */     return rMap;
/* 407:    */   }
/* 408:    */   
/* 409:    */   public Map<String, Object> thbz(Map<String, Object> model)
/* 410:    */   {
/* 411:542 */     Map<String, Object> params = getParams(model);
/* 412:    */     
/* 413:544 */     Map<String, Object> config = getConfig(model);
/* 414:    */     
/* 415:546 */     Map<String, Object> rMap = getRMap();
/* 416:    */     try
/* 417:    */     {
/* 418:549 */       String[] IDs = MapUtil.getString(params, "IDs").split(",");
/* 419:551 */       for (int i = 0; i < IDs.length; i++)
/* 420:    */       {
/* 421:553 */         params.put(MapUtil.getString(config, "module.idCol"), IDs[i].trim());
/* 422:    */         
/* 423:555 */         params.putAll((Map)getSqlSessionTemplate().selectOne(namespace(config) + ".get", params));
/* 424:    */         
/* 425:    */ 
/* 426:558 */         getSqlSessionTemplate().delete(namespace(config) + ".thbz", params);
/* 427:    */       }
/* 428:561 */       rMap.put("data", getSqlSessionTemplate().selectOne(namespace(config) + ".get", params));
/* 429:    */     }
/* 430:    */     catch (Exception ex)
/* 431:    */     {
/* 432:565 */       rMap.put("success", Boolean.valueOf(false));
/* 433:567 */       if (MapUtil.getBoolean(rMap, "shoeExMessage").booleanValue()) {
/* 434:569 */         rMap.put("message", ex.getMessage());
/* 435:    */       } else {
/* 436:573 */         rMap.put("message", "数据加锁出错！请稍后重试，或联系系统管理员！");
/* 437:    */       }
/* 438:576 */       rMap.put("ex", ex.getMessage());
/* 439:    */       
/* 440:578 */       ex.printStackTrace();
/* 441:    */     }
/* 442:581 */     afterLock(model, rMap);
/* 443:    */     
/* 444:583 */     return rMap;
/* 445:    */   }
/* 446:    */ }


/* Location:           D:\Users\Desktop\shanxi\项目\sxazmis\WEB-INF\classes\
 * Qualified Name:     com.rinsi.app.azsb.AzsbService
 * JD-Core Version:    0.7.0.1
 */